﻿using APIDataManage.XmlToJson;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace APIDataManage.XmlToDB
{
    public class FleetOperatorsXml
    {
        public void insertFleetOperatorsToDB(string id_ope="")
        {
            APIDataFunction api = new APIDataFunction();
            XmlDocument doc = api.getFleetOperators(id_ope);
            if(doc != null)
            {
                XmlElement root = doc.DocumentElement;

                dynamic optxml = XDocument.Parse(doc.InnerXml);
                
                string optStr = JsonConvert.SerializeXNode(optxml);

                ConvertXmlHelper convertXmlToJson = new ConvertXmlHelper();
                string strJson = convertXmlToJson.XmlToJSON(doc);

                dynamic operatorsJson = JValue.Parse(strJson);

                var operatorsObj = operatorsJson.operators;

                //var c = b.operators;
            }

        }
    }
}
